package com.sojson.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.sojson.base.impl.BaseDaoImpl;
import com.sojson.dao.AddressesDao;
import com.sojson.entity.po.Addresses;

/**
 * 收货地址表Dao实现类(目的:把分页插件从Service层分离,这样就不用每次调Dao接口都要分页)
 * 
 * @author liu
 * @date 2021-03-19
 */
@Repository
public class AddressesDaoImpl extends BaseDaoImpl<AddressesDao, Addresses> implements AddressesDao {

    @Resource
    private AddressesDao addressesDao;

    /**
     * 单条插入
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(Addresses addresses) {
        return addressesDao.insert(addresses);
    }

    /**
     * 批量插入
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(List<Addresses> addressess) {
        return addressesDao.insertList(addressess);
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(Addresses addresses) {
        return addressesDao.deleteByDto(addresses);
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        return addressesDao.countAll();
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<Addresses> listAll() {
        return addressesDao.listAll();
    }

    /**
     * 根据对象统计数量
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(Addresses addresses) {
        return addressesDao.countByDto(addresses);
    }

    /**
     * 根据对象查询
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public List<Addresses> listByDto(Addresses addresses) {
        startPageDefaultSort(addresses);
        return addressesDao.listByDto(addresses);
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        return addressesDao.deleteById(id);
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(ArrayList<Integer> ids) {
        return addressesDao.deleteByIdList(ids);
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(Addresses addresses) {
        return addressesDao.updateById(addresses);
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(Addresses addresses) {
        return addressesDao.updateStaticByIdList(addresses);
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param addressess
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(ArrayList<Addresses> addressess) {
        return addressesDao.updateChangeByIdList(addressess);
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(Addresses addresses) {
        return addressesDao.updatePartialById(addresses);
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(Addresses addresses) {
        return addressesDao.updateStaticPartialByIdList(addresses);
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param addressess
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(ArrayList<Addresses> addressess) {
        return addressesDao.updateChangePartialByIdList(addressess);
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public Addresses findById(Integer id) {
        return addressesDao.findById(id);
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Addresses> findByIdList(ArrayList<Integer> ids) {
        return addressesDao.findByIdList(ids);
    }

    /**
     * 通过对象查询id列表
     * 
     * @param addresses
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findIdByDto(Addresses addresses) {
        return addressesDao.findIdByDto(addresses);
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        addressesDao.clear();
    }

    /**
     * 修改收货地址为非默认
     * 
     * @param mId
     * @return
     */
    @Override
    public int updateIsDefaultToNoByMId(Integer mId) {
        return addressesDao.updateIsDefaultToNoByMId(mId);
    }

    /**
     * 修改收货地址为默认
     * 
     * @param id
     * @return
     */
    @Override
    public int updateIsDefaultToYesById(Integer id) {
        return addressesDao.updateIsDefaultToYesById(id);
    }

}